package com.fuxi.cloud.desreport.render.utils;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * RegexMatches
 *
 * @Author: 扫地僧
 * @CreateTime: 2021-05-03
 */
public class RegexMatches {
    public static final String a = "\\{([a-zA-Z0-9_\\u4e00-\\u9fa5]+).(\\S+)}";
    public static final String b = "([a-zA-Z0-9]+).(\\S+)";
    public static final String c = "([0-9]+)";
    public static final String d = "([A-Z]+)";
    public static final String e = "([A-Z]+)";
    public static final String f = "([A-Z]{1,2})([0-9]+)";
    public static final String g = "^#\\{.*\\[a-zA-Z\\+]\\}$";
    public static final String h = "^([a-zA-Z]*)\\((.*)\\)$";

    public RegexMatches() {
    }

    public static void main(String[] args) {
        String var1 = "group(username)";
        Pattern var2 = Pattern.compile("([a-zA-Z0-9]+).(\\S+)");
        Matcher var3 = var2.matcher(var1);
        if (var3.find()) {
            System.out.println("Found value: " + var3.group(0));
            System.out.println("Found value: " + var3.group(1));
            System.out.println("Found value: " + var3.group(2));
        } else {
            System.out.println("未匹配!");
        }

        List var4 = f("=SUM(D8+D5+D6)");
        System.out.println(a("${test.name}天", 2));
    }

    public static String a(String var0, int var1) {
        if (ObjectUtil.isNotEmpty(var0)) {
            Pattern var2 = Pattern.compile("\\{([a-zA-Z0-9_\\u4e00-\\u9fa5]+).(\\S+)}");
            Matcher var3 = var2.matcher(var0);
            return var3.find() ? var3.group(var1) : null;
        } else {
            return null;
        }
    }

    public static Set<String> a(String var0) {
        if (!ObjectUtil.isNotEmpty(var0)) {
            return null;
        } else {
            HashSet var1 = new HashSet();
            Pattern var2 = Pattern.compile("([0-9]+)");
            Matcher var3 = var2.matcher(var0);

            while(var3.find()) {
                var1.add(var3.group());
            }

            return var1;
        }
    }

    public static Set<String> b(String var0) {
        if (!ObjectUtil.isNotEmpty(var0)) {
            return null;
        } else {
            HashSet var1 = new HashSet();
            Pattern var2 = Pattern.compile("([A-Z]+)");
            Matcher var3 = var2.matcher(var0);

            while(var3.find()) {
                var1.add(var3.group());
            }

            return var1;
        }
    }

    public static Set<String> c(String var0) {
        if (ObjectUtil.isNotEmpty(var0)) {
            HashSet var1 = new HashSet();
            Pattern var2 = Pattern.compile("([A-Z]+)");
            Matcher var3 = var2.matcher(var0);

            while(var3.find()) {
                if (var3.group().length() <= 2) {
                    var1.add(var3.group());
                }
            }

            return var1;
        } else {
            return null;
        }
    }

    public static List<String> d(String var0) {
        if (!ObjectUtil.isNotEmpty(var0)) {
            return null;
        } else {
            ArrayList var1 = new ArrayList();
            Pattern var2 = Pattern.compile("^([a-zA-Z]*)\\((.*)\\)$");
            Matcher var3 = var2.matcher(var0);

            while(var3.find()) {
                var1.add(var3.group(0));
                var1.add(var3.group(1));
                var1.add(var3.group(2));
            }

            return var1;
        }
    }

    public static String b(String var0, int var1) {
        if (ObjectUtil.isNotEmpty(var0)) {
            Pattern var2 = Pattern.compile("([a-zA-Z0-9]+).(\\S+)");
            Matcher var3 = var2.matcher(var0);
            return var3.find() ? var3.group(var1) : null;
        } else {
            return null;
        }
    }

    public static JSONObject e(String var0) {
        StringBuffer var1 = new StringBuffer();
        if (!ObjectUtil.isNotEmpty(var0)) {
            return null;
        } else {
            String var2 = "[\\\"' ]*[^:\\\"' ]*[\\\"' ]*:";
            Pattern var3 = Pattern.compile(var2);
            Matcher var4 = var3.matcher(var0);

            while(var4.find()) {
                var4.appendReplacement(var1, var4.group().toLowerCase());
            }

            var4.appendTail(var1);
            return JSONObject.parseObject(var1.toString());
        }
    }

    public static List<String> f(String var0) {
        if (!ObjectUtil.isNotEmpty(var0)) {
            return null;
        } else {
            ArrayList var1 = new ArrayList();
            Pattern var2 = Pattern.compile("([A-Z]{1,2})([0-9]+)");
            Matcher var3 = var2.matcher(var0);

            while(var3.find()) {
                var1.add(var3.group(0));
                var1.add(var3.group(1));
                var1.add(var3.group(2));
            }

            return var1;
        }
    }

    public static List<String> g(String var0) {
        if (!ObjectUtil.isNotEmpty(var0)) {
            return null;
        } else {
            ArrayList var1 = new ArrayList();
            Pattern var2 = Pattern.compile("\\{([a-zA-Z0-9_\\u4e00-\\u9fa5]+).(\\S+)}");
            Matcher var3 = var2.matcher(var0);

            while(var3.find()) {
                String var4 = var3.group(2);
                List var5 = Arrays.asList(var4.split("[\\+\\,\\-\\*\\/]{1}"));
                var1.addAll(var5);
            }

            return var1;
        }
    }

    public static JSONArray a(List<Map<String, Object>> var0) {
        StringBuffer var1 = new StringBuffer();
        if (!ObjectUtil.isNotEmpty(var0)) {
            return null;
        } else {
            String var2 = "[\\\"' ]*[^:\\\"' ]*[\\\"' ]*:";
            Pattern var3 = Pattern.compile(var2);
            Matcher var4 = var3.matcher(JSON.toJSONString(var0));

            while(var4.find()) {
                var4.appendReplacement(var1, var4.group().toLowerCase());
            }

            var4.appendTail(var1);
            return JSON.parseArray(var1.toString());
        }
    }
}

